using System;
using Academia.BI;
using Page=System.Web.UI.Page;

public partial class _Default : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!(Page.IsPostBack))
        //{
        //    SqlDataManager.ExecuteNonQuery("if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[VPessoa]') and OBJECTPROPERTY(id, N'IsView') = 1) drop view [dbo].[VPessoa]");
        //    SqlDataManager.ExecuteNonQuery("CREATE VIEW VPessoa AS SELECT * FROM Pessoa");
        //    Session.Add("Filter", "PessoaAll");
        //}
        //lnkSetSession.ForeColor = ((Session["Filter"] == "PessoaAll") ? System.Drawing.Color.Gray : System.Drawing.Color.White);
    }

    protected void lnkSetSession_Click(object sender, EventArgs e)
    {
        //DropView();
        //if (Session["Filter"] == "PessoaAll")
        //{
        //    Session["Filter"] = "PessoaFilter";
        //    lnkSetSession.ForeColor = System.Drawing.Color.White;
        //    CreateView(" WHERE CA = 1 ");
        //}
        //else
        //{
        //    Session["Filter"] = "PessoaAll";
        //    lnkSetSession.ForeColor = System.Drawing.Color.Gray;
        //    CreateView(String.Empty);
        //}
        //grdAniversariantes.DataBind();
    }

    private void DropView()
    {
        string sql = "DROP VIEW VPessoa";
        SqlDataManager.ExecuteNonQuery(sql);
    }

    private void CreateView(string where)
    {
        string sql = String.Format("CREATE VIEW VPessoa AS Select * FROM Pessoa {0}", where);
        SqlDataManager.ExecuteNonQuery(sql);
    }
}